#ifndef _COBJECT_H_
#define _COBJECT_H_

#include <d3dx9.h>
#include "Sprite.h"
//#include "Camera.h"
#include "DxInput.h"
#include "Collision.h"

#include <list>
using namespace std;


enum OBJECT_TYPE
{	 
	OBJECT_LAND, 
	OBJECT_STAIR,	
	OBJECT_SCENE,
	OBJECT_ENEMY,
	OBJECT_ITEM
};

class Object
{
protected:
	Sprite* p_sprite;		//hinh anh cua doi tuong

	float pos_x;			//vi tri X cua doi tuong
	float pos_y;			//vi tri Y cua doi tuong

	float pos_x_old;		//vi tri X cu cua obj
	float pos_y_old;		//vi tri Y cu cua obj

	RECT rect_bond;			//khung vien cua doi tuong, xet va cham
	
	int id_obj;				//id cua obj trong quadtree
	int id_obj_type;			//loai obj trong game

	//float pos_x2;
	//float pos_y2;

	float width, height;		//chieu cao, chieu rong doi tuong
	float veloc_x, veloc_y;		//van toc theo truc X, truc Y

	float accel_x;			//gia toc theo truc X
	float accel_y;			//gia toc theo truc Y

	int obj_state;				//trang thai cua obj
	int direction;			//Huong cua obj dong khi load map

	int blood;				//obj dynamic, enemy, simon
	bool is_left_die;		//for simon, direction when simon die

	//////////////////////////////////////////////////////////////////////////
	bool isChangeState;		//kiem tra obj da chuyen trang thai chua, su dung o cac item

	bool numCoinZero;		//kiem tra coin voi Coin 5 Hidden

	bool isActiveMushRoom;	//kiem tra nam nho hay la hoa
	Object* container;		//Obj chua doi tuong coin 5 hidden
public:
	
	
	

	/************************************************************************/
	/* contructor/destructor                                                                     */
	/************************************************************************/
	Object();
	Object(float x, float y);
	Object(float x, float y, int obj_id, int obj_state);
	~Object();


	/************************************************************************/
	/* get - set properties                                                 */
	/************************************************************************/

	void setIsLeftDie(bool is_left_die) {this->is_left_die = is_left_die;}
	int getBlood() {return blood;}
	void setBlood(int blood) {this->blood = blood;}
	
	float getPosX() { return pos_x; }
	float getPosY() { return pos_y; }
	void setPosX(float x) {pos_x = x;}
	void setPosY(float y) {pos_y = y;}
	int getIDObjType() { return id_obj_type; }
	void setIDObjType(int obj_type) { this->id_obj_type = obj_type; }
	int getIDObj() { return id_obj; }
	void setIDObj(int id_obj) { this->id_obj = id_obj; }

	/*float getPosX2() { return pos_x2; }
	float getPosY2() { return pos_y2; }*/

	float getPosXOld() { return pos_x_old; }
	float getPosYOld() { return pos_y_old; } 
	

	float getVelocX() { return veloc_x; }
	float getVelocY() { return veloc_y; }
	void setVelocX(float vx) {veloc_x = vx;}
	void setVelocY(float vy) {veloc_y = vy;}

	float getAccelX() {return accel_x;}
	float getAccelY() {return accel_y;}
	void setAccelX(float accel_x) {this->accel_x = accel_x;}
	void setAccelY(float accel_y) {this->accel_y = accel_y;}

	float getWidth() { return width; }
	float getHeight() { return height; }

	Box getBox(float delta_time);

	Sprite* getSprite() {return p_sprite;}

	int getObjState() {return obj_state;}
	void setObjState(int state) {obj_state = state;}	

	virtual OBJECT_TYPE getObjectType();							//mac dinh la obj scene
	virtual bool getWay();

	void setIsChangeState(bool isChangeState) {this->isChangeState = isChangeState;}
	bool getIsChangeState() {return isChangeState;}

	int getDirection() {return direction;}

	bool getNumCoinZero() {return numCoinZero;}

	bool getIsActiveMushroom() {return isActiveMushRoom;}
	void setIsActiveMushroom(bool isActive) {isActiveMushRoom = isActive;}
	Object *getContainer() {return container;}
	void setContainer(Object* obj) {container = obj;}

	/************************************************************************/
	/* method                                                                     */
	/************************************************************************/
	
	virtual void render(int cameraX, int cameraY);					//ham ao: ve doi tuong 
	virtual void update(list<Object*>* obj_list, DxInput* input, float TPF);	//ham ao: update vi tri doi tuong theo thoi gian

	virtual void update(list<Object*>* obj_list, DxInput* input, float TPF, Object* simon);	//ham update cho cac enemy

	virtual void changeState(int obj_state) {this->obj_state = obj_state;}
	 
};
#endif